package com.test04_数组;

import org.junit.Test;

/**
 * 数组使用
 */
public class YootkDemo_01 {

    @Test
    public void test1() {
        {
            int data[] = new int[3];
            System.out.print(data[0] + "、");
            System.out.print(data[1] + "、");
            System.out.println(data[2]);
        }
        {
            int data[] = new int[]{10, 20, 30};
            data[0] *= 2;
            data[1] += 2;
            data[2] = data[0] + data[1];
            System.out.print(data[0] + "、");
            System.out.print(data[1] + "、");
            System.out.println(data[2]);
        }
    }

    @Test
    public void test2() {
        {
            int data[] = new int[10];
            for (int x = 0; x < 10; x++) {
                data[x] = x;
            }
            for (int x = 0; x < 10; x++) {
                System.out.print(data[x] + "、");
            }
        }
        {
            int data[] = {1, 2, 3, 4, 5};
            System.out.println("\n数组长度：" + data.length);
            for (int x = 0; x < data.length; x++) {
                System.out.print(data[x] + "、");
            }
        }
    }
}
